package com.nutquest.common.dataobjects;

import java.io.*;
import java.util.ArrayList;

/**
 * This class exists as the ground in the nut quest game.
 */
public class Terrain implements ICoordinate, ICarry, Serializable {
	private int x = -1;
	private int y = -1;
	private ArrayList<Object> objects;
	private TerrainType type;

	/**
	 * Constructor
	 * 
	 * @args type The type of Terrain that this object is. Tree Terrain is
	 *       impasseble, and Grass isn't.
	 */
	public Terrain(TerrainType type, int x, int y) {
		this.x = x;
		this.y = y;
		this.type = type;
		this.objects = new ArrayList<Object>();
	}

	/**
	 * Constructor
	 * 
	 * @args type The type of Terrain that this object is. Tree Terrain is
	 *       impasseble, and Grass isn't.
	 * @args objects The collection of objects that this Terrain object
	 *       contains, usually nuts.
	 */
	public Terrain(TerrainType type, ArrayList<Object> objects, int x, int y) {
		this.x = x;
		this.y = y;
		this.type = type;
		this.objects = objects;
	}

	/**
	 * Getter for the TerrainType
	 */
	public TerrainType getType() {
		return this.type;
	}

	/**
	 * Set X.
	 */
	public void setX(int x) {
		this.x = x;
	}

	/**
	 * Set Y.
	 */
	public void setY(int y) {
		this.y = y;
	}

	/**
	 * Get X.
	 */
	public int getX() {
		return this.x;
	}

	/**
	 * Get Y.
	 */
	public int getY() {
		return this.y;
	}

	/**
	 * Get the contents of this Terrain object.
	 */
	public ArrayList<Object> getObjects() {
		return objects;
	}

	/**
	 * Set the contents of this Terrain object.
	 */
	public void setObjects(ArrayList<Object> objects) {
		this.objects = objects;
	}
	
	

	/**
	 * This Enum defines what terrain types exist.
	 * 
	 * Access this class by typing "Terrain.TerrainType.GRASS"
	 */
	public enum TerrainType {
		// GRASS ENUM (BASIC OLD ENUMS WITH)
		GRASS, TREE, WATER,

		// TREE CORE ENUMS
		TREE_CORE_CORE, TREE_CORE_MID_LEFT, TREE_CORE_MID_RIGHT, TREE_CORE_MID_BOT, TREE_CORE_MID_TOP, TREE_CORE_BOT_LEFT, TREE_CORE_BOT_RIGHT, TREE_CORE_TOP_LEFT, TREE_CORE_TOP_RIGHT,

		// TREE ROOT ENUMS
		TREE_ROOT_BOT_BASE, TREE_ROOT_BOT_MID, TREE_ROOT_BOT_TIP, TREE_ROOT_LEFT_BASE, TREE_ROOT_LEFT_MID, TREE_ROOT_LEFT_TIP, TREE_ROOT_RIGHT_BASE, TREE_ROOT_RIGHT_MID, TREE_ROOT_RIGHT_TIP, TREE_ROOT_TOP_BASE, TREE_ROOT_TOP_MID, TREE_ROOT_TOP_TIP,

		// ROCK ENUMS
		ROCK_BOT_LEFT, ROCK_BOT_RIGHT, ROCK_TOP_LEFT, ROCK_TOP_RIGHT,

		// BUSH ENUMS
		BUSH_BOT_RIGHT, BUSH_BOT_LEFT, BUSH_TOP_RIGHT, BUSH_TOP_LEFT,

		// POND ENUMS
		// top edge of pond
		POND_00, POND_10, POND_20, POND_30, POND_40,
		// left edge of pond
		POND_01, POND_02, POND_03,
		// right edge of pond
		POND_41, POND_42, POND_43,
		// bottom edge of pond
		POND_04, POND_14, POND_24, POND_34, POND_44,
		// pond filling
		POND_XX,

		// SPAWNPAD ENUMS
		SPAWN_TOP_LEFT, SPAWN_TOP_RIGHT, SPAWN_BOT_LEFT, SPAWN_BOT_RIGHT,
	}



	@Override
	public boolean hasObjects() {
		// TODO Auto-generated method stub
		if(this.objects != null)
		{
			if(this.objects.size() > 0)
				return true;
		}
		return false;
	}

}